#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <list>
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_CommHdr.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_Types.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_ProtocolHdr.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine_Client/NetClient_Socket/NetClient_Define.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine_Client/NetClient_Socket/NetClient_Error.h"

//g++ -std=gnu++11 -Wall -g Test_UDXClient.cpp -o TestS_UDXClient -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib -L ../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Client -lNetEngine_BaseLib -lNetClient_Socket -Wl,-rpath=../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_BaseLib:../../../NetEngine_Linux/NetEngine_Release/NetEngine_Release/NetEngine_Client,--disable-new-dtags

int main()
{
    LPCTSTR lpszFile = _T("./Test_UDXClient.exe");
    XNETHANDLE xhNet;

    FILE *pSt_File = _tfopen(lpszFile, "rb");
    if (NULL == pSt_File)
    {
        printf(_T("打开文件失败\n"));
        return -1;
    }
    NETCLIENT_UDXCONFIG st_UDXConfig;
    memset(&st_UDXConfig,'\0',sizeof(NETCLIENT_UDXCONFIG));

    st_UDXConfig.bEnableLogin = TRUE;
    st_UDXConfig.bEnableReorder = TRUE;
    st_UDXConfig.bEnableRryTime = TRUE;
    st_UDXConfig.nWindowSize = 1000;

    if (!NetClient_UDXSocket_InitEx(&xhNet, &st_UDXConfig, "192.168.1.109", 1339))
    {
        printf(_T("初始化失败,启动错误:%lX\n"),NetClient_GetLastError());
        return -1;
    }
    printf(_T("登录成功\n"));

    while (1)
    {
        TCHAR tszMsgBuffer[2048];
        memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
        int nRet = fread(tszMsgBuffer, 1, sizeof(tszMsgBuffer), pSt_File);
        if (nRet <= 0)
        {
            break;
        }
        NetClient_UDXSocket_SendEx(xhNet, tszMsgBuffer, nRet);
        Sleep(30);
    }

    NetClient_UDXSocket_DestroyEx(xhNet);

    return 0;
}
